﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace AiChiTu.TraceabilitySystem.Infrastructure.Interfaces
{
	/// <summary>
	/// 泛型仓储接口
	/// struct	值类型		int , float , double , bool , long , struct			内存栈上分配
	/// class	引用类型	string , object , arry , list ,dictionary ,class	内存堆上分配
	/// </summary>
	/// <typeparam name="T">实体</typeparam>
	public interface IBaseRepository<T> where T : class
	{
		Task<bool> CreateEntityAsync(T entity);
		Task<bool> CreateEntitiesAsync(IEnumerable<T> entities);
		Task<bool> UpdateEntityAsync(T entity);
		Task<bool> UpdateEntitiesAsync(IEnumerable<T> entities);
		Task<bool> DeletedEntityAsync(T entity);
		Task<bool> DeletedEntitiesAsync(IEnumerable<T> entities);
		Task<T?> QueryEntityAsync(int id);
		Task<T?> QueryEntityAsync(Expression<Func<T, bool>> expression);
		IQueryable<T> QueryAllAsync();
		IQueryable<T> QueryAllAsync(Expression<Func<T, bool>> expression);
	}
}
